//2009/08/15 16:48:05
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <math.h>
#include <algorithm>

using namespace std;

class ManhattanMovement
{
public:
    double getDistance(int A, int B, int x, int y)
    {
		//pay attention to the type cast.
		double a = A, b = B, x0 = x, y0 = y;
		if(a == 0) return fabs(y0 - 1.0 / b );
		if(b == 0) return fabs(x0 - 1.0 / a );
		double dis1 = fabs(y0 - (1.0 - a * x0) / b);
		double dis2 = fabs(x0 - (1.0 - b * y0) / a);
		return min(dis1, dis2);
    }
};
